﻿using System;

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            var dateTime = DateTime.Now;

            Console.WriteLine(dateTime.ToString("yyyy-MM-dd hh:mm"));/*格式重写编辑格式  重写格式用其英文名称的首字母月份要大写*/
            Console.WriteLine(dateTime.Date);
            Console.WriteLine(dateTime.TimeOfDay);

            var firstTime = "2020.6.6";
            var secondTime = Convert.ToDateTime(firstTime);/*并没有把现在的时间改变只是赋值发生改变*/
            var reduceDay = secondTime.AddDays(-1);
            var aYear = reduceDay.AddYears(-20);

            Console.WriteLine(dateTime);

            Console.WriteLine(reduceDay.Date);
            Console.WriteLine(reduceDay);
            Console.WriteLine(aYear.Day);
            Console.WriteLine(aYear.DayOfWeek);

            var nowTime = DateTime.Now;
            var newTime = new DateTime(2000, 8, 23);/*  . 隔开*/
            var result = nowTime - newTime;

            Console.WriteLine(result);
            Console.WriteLine(result.TotalMinutes);

            var name = "活到老学到老,老到学不动还在学";
            var nameFirstNumber = name.IndexOf("老");
            var nameLastNumber = name.LastIndexOf("学");
            var nameReplace = name.Replace("到", "好好");
            var nameSubString = name.Substring(6);/*从第n+1个开始*/
            var nameInsert = name.Insert(6, "老到不行还写老,");

            Console.WriteLine(nameFirstNumber);
            Console.WriteLine(nameLastNumber);
            Console.WriteLine(nameReplace);
            Console.WriteLine(nameSubString);
            Console.WriteLine(nameInsert);

            int i = 6;
            double n = i;

            Console.WriteLine(n.ToString("0.000000"));
        }
    }
}
